<style>
    .ace_editor {
        height: 500px;
    }
</style>


<div class="hbox hbox-auto-xs hbox-auto-sm" ng-init="
    app.settings.asideFolded = false;
    app.settings.asideDock = false;
  ">
    <!-- main -->
    <div class="col">
        <!-- main header -->
        <div class="bg-light lter b-b wrapper-md">
            <div class="row">
                <div class="col-sm-6 col-xs-12">
                    <h1 class="m-n font-thin h3 text-black">服务映射</h1>
                    <small class="text-muted">自助服务</small>
                </div>
            </div>
        </div>
        <!-- / main header -->
        <div class="wrapper-md">
            <!-- toaster directive -->
            <toaster-container
                    toaster-options="{'position-class': 'toast-top-right', 'close-button':true}"></toaster-container>
            <!-- / toaster directive -->

            <uib-tabset>
                <uib-tab index="0" heading="帮助">
                    <div class="panel panel-default" ng-controller="nginxTcpHelpCtrl">
                        <div style="margin-top: 5px;" class="panel">
                            <div class="panel-body">
                                <form class="form-horizontal col-md-12" style="box-shadow: 0 0 5px #ddd;padding: 10px;">
                                    <div ng-show="!mdEditing" ng-bind-html="md.preview"></div>

                                    <div ng-show="mdEditing" ui-ace="aceOption" ng-model="md.mdBody"
                                         class="ace_editor"></div>
                                </form>
                            </div>
                            <div class="form-group" style="text-align:center;">
                                <button class="btn btn-xs" ng-show="!mdEditing"
                                        style="margin-right: 5px; background-color: #2b669a; color: white;"
                                        ng-click="editMD()">
                                    <i class="glyphicon glyphicon-edit"></i>编辑公告
                                </button>

                                <button class="btn btn-xs" ng-show="mdEditing"
                                        style="margin-right: 5px; background-color: #ff8700; color: white;"
                                        ng-click="saveMD()">
                                    <i class="glyphicon glyphicon-ok"></i>保存公告
                                </button>
                            </div>
                        </div>
                    </div>
                </uib-tab>
                <uib-tab index="1" heading="服务映射">
                    <div class="panel panel-default" ng-controller="nginxTcpCtrl">
                        <div class="panel-body">

                            <form class="form-inline" role="form">
                                <div class="form-group">
                                    <div class="input-group">
                                        <span class="input-group-addon">名称</span>
                                        <input type="text" class="form-control" ng-model="queryName" placeholder="名称">
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="input-group">
                                        <span class="input-group-addon">环境类型</span>
                                        <select class="form-control" ng-model="nowEnv"
                                                ng-options="envItem.code as envItem.name for envItem in envType"
                                                required>
                                            <option value="">--请选择--</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <button type="button" class="btn btn-info" ng-click="doQuery()"><span
                                            class="glyphicon glyphicon-search"></span>搜索
                                    </button>
                                    <button type="button" class="btn btn-info" ng-click="reSet()"><span
                                            class="glyphicon glyphicon-repeat"></span>重置
                                    </button>
                                    <button type="button" class="btn btn-success"
                                            ng-if="contains(authPoint, '/nginx/tcp/auto')"
                                            ng-click="autoNginxTcp()">
                                        <span class="fa fa-spin fa-spinner" ng-show="btnAuto"></span>
                                        <span class="icon icon-cursor" ng-show="!btnAuto"></span>自动配置
                                    </button>
                                    <button type="button" class="btn btn-success"
                                            ng-if="contains(authPoint, '/nginx/tcp/scan')"
                                            ng-click="scanNginxTcp()">
                                        <span class="fa fa-spin fa-spinner" ng-show="btnScan"></span>
                                        <span class="icon icon-cursor" ng-show="!btnScan"></span>重新扫描
                                    </button>
                                    <button type="button" class="btn btn-success" ng-click="createNginxTcp()"><span
                                            class="glyphicon glyphicon-plus"></span>新增
                                    </button>
                                </div>
                            </form>

                            <div class="panel panel-default" style="margin-top: 5px;">
                                <div class="panel-body">
                                    <div>
                                        <table class="table table-hover table-bordered table-striped">
                                            <thead>
                                            <tr>
                                                <td>服务名称</td>
                                                <td>服务器组</td>
                                                <td>端口类型</td>
                                                <td>域名:端口(办公网可访问)</td>
                                                <td>环境</td>
                                                <td>创建者</td>
                                                <td>过期时间</td>
                                                <td>操作</td>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <tr ng-repeat="item in pageData">
                                                <td>
                                                    <b style="color: #286090">{{item.serviceName}}</b>
                                                </td>
                                                <td>
                                                    <b style="color: #777">{{item.serverGroupName}}</b>
                                                </td>
                                                <td>
                                                    {{item.portName}}
                                                </td>
                                                <td>
                                                    {{item.domain}}:{{item.nginxPort}}
                                                </td>
                                                <td>
                                                    <b style="color:{{item.env.color}}">{{item.env.name}}</b>
                                                </td>
                                                <td>
                                                    {{item.displayName}}
                                                </td>
                                                <td>{{item.gmtExpired}}</td>
                                                <td>
                                                    <button ng-click="delNginxTcp(item.id)"
                                                            class="btn btn-xs pull-right"
                                                            style="background-color: red; color: white;">
                                                        <span class="glyphicon glyphicon-remove"></span>销毁
                                                    </button>
                                                </td>
                                            </tr>
                                            </tbody>
                                            <tfoot>
                                            <tr>
                                                <td colspan="10">
                                                    <ul style="margin: 0px; float: right;" uib-pagination
                                                        total-items="totalItems" ng-model="currentPage"
                                                        items-per-page="pageLength" max-size="10"
                                                        ng-change="pageChanged()" previous-text="&lsaquo;"
                                                        next-text="&rsaquo;"></ul>
                                                </td>
                                            </tr>
                                            </tfoot>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </uib-tab>
                <uib-tab index="2" heading="Dubbo直连配置">
                    <div class="panel panel-default" ng-controller="nginxTcpDubboHelpCtrl">
                        <div style="margin-top: 5px;" class="panel">
                            <div class="panel-body">
                                <form class="form-horizontal col-md-12" style="box-shadow: 0 0 5px #ddd;padding: 10px;">
                                    <div ng-show="!mdEditing" ng-bind-html="md.preview"></div>

                                    <div ng-show="mdEditing" ui-ace="aceOption" ng-model="md.mdBody"
                                         class="ace_editor"></div>
                                </form>
                            </div>
                            <div class="form-group" style="text-align:center;">
                                <button class="btn btn-xs" ng-show="!mdEditing"
                                        style="margin-right: 5px; background-color: #2b669a; color: white;"
                                        ng-click="editMD()">
                                    <i class="glyphicon glyphicon-edit"></i>编辑公告
                                </button>

                                <button class="btn btn-xs" ng-show="mdEditing"
                                        style="margin-right: 5px; background-color: #ff8700; color: white;"
                                        ng-click="saveMD()">
                                    <i class="glyphicon glyphicon-ok"></i>保存公告
                                </button>
                            </div>
                        </div>
                    </div>
                </uib-tab>
            </uib-tabset>
        </div>
    </div>
    <!-- / main -->
</div>

<script type="text/ng-template" id="tcpCreateInfo">
    <div ng-include="'tpl/modal/nginx/tcp_create_modal.html'"></div>
</script>

